package com.sise.controller.wechat;

import com.sise.bean.CodeMsg;
import com.sise.entity.ReceiverInfo;
import com.sise.service.IReceiverInfoService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zj
 */
@RestController
@RequestMapping("/sise/wechat/receiver-info")
public class WechatReceiverInfoController {

    @Resource
    private IReceiverInfoService receiverInfoService;

    @PostMapping("/save")
    public CodeMsg saveReceiverInfo(@RequestBody ReceiverInfo receiverInfo) {
        return receiverInfoService.saveReceiverInfo(receiverInfo);
    }

    @PostMapping("/deleteById")
    public CodeMsg deleteById(@RequestBody ReceiverInfo receiverInfo) {
        return receiverInfoService.deleteById(receiverInfo);
    }

    @PostMapping("/updateById")
    public CodeMsg updateReceiverInfoById(@RequestBody ReceiverInfo receiverInfo) {
        return receiverInfoService.updateReceiverInfoById(receiverInfo);
    }

    @RequestMapping("/findByOpenId")
    public List<ReceiverInfo> findByOpenId(String openId) {
        return receiverInfoService.findByOpenId(openId);
    }

    @RequestMapping("/findDefaultByOpenId")
    public ReceiverInfo findDefaultByOpenId(String openId) {
        return receiverInfoService.findDefaultByOpenId(openId);
    }

}
